package com.example.malllocationserver.repository.Impl;

import com.example.malllocationserver.entity.History;
import com.example.malllocationserver.entity.User;
import com.example.malllocationserver.mapper.UserMapper;
import com.example.malllocationserver.repository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.sql.Timestamp;
import java.util.List;

@Repository
public class UserRepositoryImpl implements UserRepository {
    @Autowired
    UserMapper userMapper;
    @Override
    public List<User> findAll() {
        return userMapper.findAll();

    }
    @Override
    public void register(String userId, String userName,String password,String phone,String sex, Timestamp reg_time) {
        userMapper.register(userId, userName,password,phone,sex,reg_time);
    }
    @Override
    public User login(String userId, String password) {
        return userMapper.login(userId,password);
    }

    @Override
     public boolean updatePhone(String userId,String phone){return userMapper.updatePhone(userId,phone);}
    @Override
    public boolean updatePassword(String userid,String password){return userMapper.updatePassword(userid,password);}
    @Override
    public User find(String username){ return userMapper.find(username); }

    @Override
    public List<History> find_history(String userid){return userMapper.find_history(userid);}

    public boolean delete_history(String userid){return userMapper.delete_history(userid);}
    public boolean addHistory(String userid,String storename, Timestamp time){return userMapper.addHistory(userid,storename,time);}
    public User getUser(String userid){return userMapper.getUser(userid);}
    public boolean save(String userid,String picture){return userMapper.save(userid,picture);};
}


